﻿<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
    Inherits="Nivdal.ApproveUsers" Title=" Approve users - Nivdal.com!"
    StylesheetTheme="SkinFile" CodeBehind="ApproveUsers.aspx.cs" %>

<asp:Content ID="PageNameContent" ContentPlaceHolderID="PageNamePlaceHolder" runat="server">
    <asp:Label ID="PageNameLabel" runat="server" Text="<%$ Resources:Resource, ApproveUsers_PageNameLabel %>"
        CssClass="PageNameContentStyle"></asp:Label>
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <asp:HiddenField ID="UserIdHiddenField" runat="server" />
    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
        <ContentTemplate>
        <div class="basic_element">
        <div class="red_title">
           <asp:Label ID="PageTitleLabel" runat="server" Text="<%$ Resources:Resource, ApproveUsers_PageNameLabel %>" CssClass="white_title" ></asp:Label>
        </div>
        <div class="padding5">
            <asp:Label ID="AccessLevelLabel" runat="server" SkinID="GreenSmallHeaderLabel"></asp:Label>
            
            <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
                <ProgressTemplate>
                    <div class="ajaxloader">
                        <asp:Image ID="ProgressImage" runat="server" ImageUrl="~/Images/ajax-loader.gif" />
                    </div>
                </ProgressTemplate>
            </asp:UpdateProgress>
            
            <asp:GridView ID="ApprovalUsersGridView" DataSourceID="UsersToApproveSqlDataSource"
                AllowPaging="True" OnRowCommand="UpdateNewUser" AutoGenerateColumns="False"
                runat="server" SkinID="Professional">
                <PagerSettings FirstPageText="<%$ Resources:Resource, FirstPage %>" LastPageText="<%$ Resources:Resource, LastPage %>"
                    Mode="NumericFirstLast" PageButtonCount="10" Position="Bottom" />
                <PagerStyle CssClass="pagination" HorizontalAlign="Center" />
                <Columns>
                    <asp:TemplateField HeaderText="<%$ Resources:Resource, ApproveUsers_UserInfoTitle %>"
                        ItemStyle-Width="40%">
                        <ItemTemplate>
                            <asp:ImageButton ID="CountryImage" runat="server" ImageUrl='<%# Eval("Flag", "~/Images/Flags/{0}") %>'
                                ToolTip='<%# Eval("CountryName") %>' PostBackUrl='<%# Eval("CountryId", "Country.aspx?Id={0}") %>' />
                            <asp:Label ID="UserNameLabel" runat="server" Text='<%# Eval("UserName") %>' SkinID="GridLabel"></asp:Label>
                            <br />
                            <asp:Label ID="TeamNameTitleLabel" runat="server" Text="<%$ Resources:Resource, Global_TeamName %>"
                                SkinID="InfoLabel"></asp:Label>
                            :&nbsp;
                            <asp:Label ID="TeamNameLabel" runat="server" Text='<%# Eval("TeamName") %>' SkinID="GridLabel"></asp:Label>
                            <br />
                            <asp:Label ID="EmailTitleLabel" runat="server" Text="<%$ Resources:Resource, Global_Email %>"
                                SkinID="InfoLabel"></asp:Label>
                            :&nbsp;
                            <asp:Label ID="EmailLabel" runat="server" Text='<%# Eval("Email") %>' SkinID="GridLabel"></asp:Label>
                            <br />
                            <asp:Label ID="LastLoginDateTitleLabel" runat="server" Text="<%$ Resources:Resource, Global_LastLogin %>"
                                SkinID="InfoLabel"></asp:Label>
                            :&nbsp;
                            <asp:Label ID="LastLoginLabel" runat="server" Text='<%# Eval("LastLoginDate") %>'
                                SkinID="GridLabel"></asp:Label>
                            <br />
                            <asp:Label ID="IPTitleLabel" runat="server" Text="IP: " SkinID="InfoLabel"></asp:Label>
                            &nbsp;
                            <asp:Hyperlink ID="IpLinkButton" runat="server" Text='<%# Eval("IP") %>' SkinID="BlackHyperLinkSkin"
                             NavigateUrl='<%# "http://www.ip2location.com/" + Eval("IP")  %>' ToolTip="Check location of this Ip addess"
                              Target="_blank" Visible='<%# Eval("IP").ToString().Length > 5 %>' ></asp:Hyperlink>
                            <br />
                            <asp:Label ID="RealNameTitleLabel" runat="server" Text="<%$ Resources:Resource, ApproveUsers_Name %>"
                                SkinID="InfoLabel"></asp:Label>
                            : &nbsp;
                            <asp:Label ID="RealNameLabel" runat="server" Text='<%# Eval("Name") %>' SkinID="GridLabel"></asp:Label>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:Label ID="UserNameTitleLabel" runat="server" Text="Username:" SkinID="InfoLabel"></asp:Label>
                            <br />
                            <asp:TextBox ID="UserNameTextbox" runat="server" Width="100" TextMode="SingleLine"
                             Text='<%# Bind("UserName") %>'></asp:TextBox>
                             <br />
                            <asp:Label ID="TeamNameTitleLabel" runat="server" Text="TeamName:" SkinID="InfoLabel"></asp:Label>
                            <br />
                            <asp:TextBox ID="TeamNameTextBox" runat="server" Text='<%# Bind("TeamName") %>'></asp:TextBox>
                            <br />
                            <asp:Label ID="CountryTitleLabel" runat="server" Text="Country:" SkinID="InfoLabel"></asp:Label>
                            <br />
                            <asp:DropDownList ID="NationalityDropDownList" runat="server" DataSourceID="NationalitiesSqlDataSource"
                                DataTextField="Name" DataValueField="Id" SelectedValue='<%# Bind("CountryId") %>'>
                            </asp:DropDownList>
                            <asp:SqlDataSource ID="NationalitiesSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                                SelectCommand="Nivdal_GetListOfActiveCountries" SelectCommandType="StoredProcedure">
                            </asp:SqlDataSource>
                            <asp:HiddenField ID="UserIdHiddenField" runat="server" Value='<%# Bind("UserId") %>' />
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="<%$ Resources:Resource, Global_Comment %>" ItemStyle-Width="40%">
                        <ItemTemplate>
                            <asp:HiddenField ID="UserIdHiddenField1" runat="server" Value='<%# Eval("UserId") %>' />
                            <asp:HiddenField ID="IPHiddenField" runat="server" Value='<%# Eval("IP") %>' />
                            <asp:ListView ID="DuplicateUsersListView" runat="server" DataSourceID="DuplicateUsersSqlDataSource">
                                <LayoutTemplate>
                                    <asp:Label ID="DuplicateIpUsers" runat="server" Text="<%$ Resources:Resource, ApproveUsers_DuplicateIPTitle %>"
                                        SkinID="GridLabel"></asp:Label>
                                    <br />
                                    <asp:Label ID="itemplaceholder" runat="server"></asp:Label>
                                </LayoutTemplate>
                                <ItemTemplate>
                                    <asp:HyperLink ID="UserNameLabel" runat="server" SkinID="GreenTitleHyperLink" Text='<%# Eval("PublicName") %>'
                                        NavigateUrl='<%# "~/UserPage.aspx?Id=" + Eval("UserId") %>'></asp:HyperLink>
                                    <asp:Label ID="EmailLabel" runat="server" SkinID="GridLabel" Text='<%# "email: " + Eval("Email") %>'></asp:Label>
                                </ItemTemplate>
                                <ItemSeparatorTemplate>
                                    <br />
                                </ItemSeparatorTemplate>
                                <EmptyDataTemplate>
                                    <asp:Label ID="NoCommentsLabel" runat="server" Text="<%$ Resources:Resource, ApproveUsers_NoComments %>"></asp:Label>
                                </EmptyDataTemplate>
                            </asp:ListView>
                            <asp:SqlDataSource ID="DuplicateUsersSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                                SelectCommand="Nivdal_FindDuplicateIP" SelectCommandType="StoredProcedure">
                                <SelectParameters>
                                    <asp:ControlParameter ControlID="UserIdHiddenField1" Name="UserId" PropertyName="Value"
                                        Type="String" />
                                    <asp:ControlParameter ControlID="IPHiddenField" Name="IP" PropertyName="Value" Type="String" />
                                </SelectParameters>
                            </asp:SqlDataSource>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField ItemStyle-Width="20%">
                        <ItemTemplate>
                            <asp:LinkButton ID="LinkButton1" runat="server" OnClientClick='return confirm(this.getAttribute("message"))'
                                message="<%$ Resources:Resource, ApproveUser_AreYouSure %>"
                                CommandArgument='<%# Eval("UserId") %>' CommandName="ApproveUser" Text="<%$ Resources:Resource, Global_Approve %>"
                                SkinID="TitleLink"></asp:LinkButton><br />
                            <asp:LinkButton ID="LinkButton2" runat="server" message="<%$ Resources:Resource, DeclineUser_AreYouSure %>"
                             OnClientClick='return confirm(this.getAttribute("message"))'
                                CommandArgument='<%# Eval("UserId") %>' CommandName="DeclineUser" Text="Decline"
                                SkinID="TitleLink"></asp:LinkButton><br />
                            <asp:LinkButton ID="LinkButton3" runat="server" OnClientClick='return confirm(this.getAttribute("message"))'
                                message="<%$ Resources:Resource, ApproveUsers_MoveToAdminUserLinkButton %>"
                                CommandArgument='<%# Eval("UserId") %>' CommandName="MoveToAdmin" Text="To admin"
                                SkinID="TitleLink"></asp:LinkButton><br />
                            <asp:LinkButton ID="EditButton" runat="server" CommandName="Edit"
                                Text="<%$ Resources:Resource, Global_Edit %>" SkinID="TitleLink"></asp:LinkButton>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:LinkButton ID="UpdateButton" runat="server" CommandName="Update" CommandArgument='<%# Eval("UserId") %>'
                                Text="<%$ Resources:Resource, Global_Update %>" SkinID="TitleLink"></asp:LinkButton>
                            <br />
                            <asp:LinkButton ID="CancelButton" runat="server" CommandName="Cancel" 
                                Text="<%$ Resources:Resource, Global_Cancel %>" SkinID="TitleLink"></asp:LinkButton>
                        </EditItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>
        </div>
        </div>
        </ContentTemplate>
    </asp:UpdatePanel>
    <asp:SqlDataSource ID="UsersToApproveSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
        SelectCommand="Nivdal_ListAllPendingAccessRequests" SelectCommandType="StoredProcedure"
        UpdateCommand="Nivdal_UpdateUserDetailsBeforeApproval" UpdateCommandType="StoredProcedure">
        <SelectParameters>
            <asp:ControlParameter ControlID="UserIdHiddenField" Name="UserId" PropertyName="Value" Type="String" />
        </SelectParameters>
    </asp:SqlDataSource>

    <asp:UpdatePanel ID="UpdateNamesPanel" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
        <div class="basic_element">
        <div class="red_title">
           <asp:Label ID="NamesToApproveTitleLabel" runat="server" CssClass="white_title" Text="<%$ Resources:Resource, ApproveUsers_PendingNameApproval %>"></asp:Label>
        </div>
        <div class="padding5">

        
        <asp:UpdateProgress ID="UpdateProgress2" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
            <ProgressTemplate>
                <div class="ajaxloader">
                    <asp:Image ID="ProgressImage2" runat="server" ImageUrl="~/Images/ajax-loader.gif" />
                </div>
            </ProgressTemplate>
        </asp:UpdateProgress>
       
        
        <asp:GridView ID="NameApprovalsGridview" runat="server" AutoGenerateColumns="false" SkinID="Professional" 
         AllowPaging="false" DataSourceID="NameApprovalsDataSource">
        <Columns>
            <asp:TemplateField>
                <ItemTemplate>
                    <asp:Image ID="FlagImage" runat="server" ImageUrl='<%# "~/Images/Flags/" + Eval("Flag") %>' Tooltip='<%# Eval("CountryName") %>' />
                    &nbsp;
                    <asp:HyperLink ID="UserHyperlink" runat="server" NavigateUrl='<%# "~/UserPage.aspx?Id=" + Eval("UserId") %>' Text='<%# Eval("UserName") %>'
                     SkinID="BlackHyperLinkSkin"></asp:HyperLink>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:Image ID="FlagImage" runat="server" ImageUrl='<%# "~/Images/Flags/" + Eval("Flag") %>' Tooltip='<%# Eval("CountryName") %>' />
                    &nbsp;
                    <asp:HyperLink ID="UserHyperlink" runat="server" NavigateUrl='<%# "~/UserPage.aspx?Id=" + Eval("UserId") %>' Text='<%# Eval("UserName") %>'
                     SkinID="BlackHyperLinkSkin"></asp:HyperLink>
                </EditItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField>
                <ItemTemplate>
                    <asp:Label ID="TeamNameLabel" runat="server" Text='<%# Eval("TeamName") %>' SkinID="GridLabel"></asp:Label>
                    <asp:HiddenField ID="UserIdHiddenField" runat="server" Value='<%# Eval("UserId") %>' />
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:HiddenField ID="UserIdHiddenField" runat="server" Value='<%# Bind("UserId") %>' />
                    <asp:TextBox ID="TeamNameTextBox" runat="server" Text='<%# Bind("TeamName") %>' Width="200" TextMode="SingleLine"></asp:TextBox>
                </EditItemTemplate>
            </asp:TemplateField>
            <asp:CommandField CancelText="<%$ Resources:Resource, Global_Cancel %>" UpdateText="<%$ Resources:Resource, Global_Update %>"
             EditText="<%$ Resources:Resource, Global_Edit %>" ButtonType="Link" ShowCancelButton="true" ShowDeleteButton="false"
              ShowEditButton="true" ShowInsertButton="false" ItemStyle-CssClass="NewsItemStyle"  />
            <asp:TemplateField>
                <ItemTemplate>
                    <asp:CheckBox ID="ApproveCheckBox" runat="server" />
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:CheckBox ID="ApproveCheckBox" runat="server" />
                </EditItemTemplate>
            </asp:TemplateField>
        </Columns>
        <EmptyDataTemplate></EmptyDataTemplate>
        </asp:GridView>
        <br />
        <asp:Button ID="ApproveAllNamesButton" runat="server" OnClick="ApproveAllNames" CssClass="GreenSmallButtonStyle" 
         Text="<%$ Resources:Resource, Admin_ApproveSelected %>" />
        <asp:SqlDataSource ID="NameApprovalsDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
            SelectCommand="Nivdal_GetTeamsForNameApproval" SelectCommandType="StoredProcedure"
            UpdateCommand="Nivdal_AdminChangeTeamName" UpdateCommandType="StoredProcedure">
            <SelectParameters>
                <asp:ControlParameter ControlID="UserIdHiddenField" Name="UserId" PropertyName="Value" Type="String" />
            </SelectParameters>
        </asp:SqlDataSource>
    </div>
    </div>
    </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
